package drafts

import (
	draftsDto "news_for_deepseek_interface/dto/admin/drafts"
	"news_for_deepseek_interface/model"
	"time"
)

func Update(params draftsDto.UpdateRequest) error {

	db := model.GetInstance().GetDB()

	if err := db.Model(&model.NewsModel{}).
		Where("id = ?", params.Id).
		Updates(map[string]interface{}{
			"type_classify_id":     params.TypeClassifyId,
			"business_classify_id": params.BusinessClassifyId,
			"title":                params.Title,
			"seo_desc":             params.SeoDesc,
			"seo_keyword":          params.SeoKeyword,
			"content":              params.Content,
			"text":                 params.Text,
			"updated_at":           time.Now(),
		}).Error; err != nil {
		return err
	}

	return nil
}
